status = -1;
var ScrollList = Array(Array(2340000, 10, 1), Array(2049752, 10, 2));
var specialItem = Array(Array(5064300, 10, 10), Array(5010102, 5, 1), Array(5010103, 5, 1), Array(2436324, 2, 1), Array(5064100, 10, 5), Array(5064003, 10, 1), Array(5062002, 10, 2));
var ChairList = Array(Array(3010007, 5, 1), Array(3010008, 5, 1));
var EquipList = Array(Array(1004975, 10, 1), Array(1051530, 10, 1), Array(1073226, 10, 1), Array(1702770, 10, 1), Array(1102823, 5, 1), Array(1102858, 5, 1), Array(1072930, 10, 1), Array(1102690, 10, 1), Array(1052875, 10, 1), Array(1004162, 10, 1), Array(1702306, 5, 1), Array(1102218, 5, 1), Array(1702624, 5, 1), Array(3018129, 10, 1), Array(1071088, 10, 1), Array(1071094, 10, 1), Array(1070071, 10, 1), Array(1032165, 10, 1), Array(1052668, 10, 1), Array(1072869, 10, 1), Array(1003975, 10, 1), Array(1004487, 10, 1), Array(1052950, 10, 1), Array(1071086, 10, 1), Array(3015642, 10, 1), Array(1003865, 10, 1), Array(1070006, 10, 1), Array(1070102, 10, 1), Array(1050188, 10, 1), Array(1051229, 10, 1), Array(1003218, 10, 1), Array(1003217, 10, 1));

function start() {
    action(1, 0, 0)
}

function action(d, e, i) {
    if (d == 1) {
        status++
    } else {
        if (status == 0) {
            im.dispose()
        }
        status--
    }
    if (status == 0) {
        if (im.getSpace(1) < 2 || im.getSpace(2) < 2 || im.getSpace(3) < 2 || im.getSpace(4) < 2 || im.getSpace(5) < 2) {
            im.sendOk("请让你的所有背包都腾出2个格子后再试。1");
            im.dispose();
            return
        } else {
            var j = "打开了箱子，一共获得了：\r\n";
            var k;
            var a = Math.floor(Math.random() * 10);
            var g = new java.util.Random().nextInt(ScrollList.length);
            var c = ScrollList[g][1];
            if (c >= a) {
                var f = ScrollList[g][0];
                var b = ScrollList[g][2];
                var h = 3;
                k = im.gainGachaponItem(f, b, "皇家礼品袋", h);
                if (k != -1) {
                    j += "#b#t" + k + "##k " + b + "个!\r\n"
                }
            }
            var g = new java.util.Random().nextInt(specialItem.length);
            c = specialItem[g][1];
            a = Math.floor(Math.random() * 10);
            if (c >= a) {
                f = specialItem[g][0];
                b = specialItem[g][2];
                h = 3;
                k = im.gainGachaponItem(f, b, "皇家礼品袋", h);
                if (k != -1) {
                    j += "#b#t" + k + "##k " + b + "个!\r\n"
                }
            }
            var g = new java.util.Random().nextInt(ChairList.length);
            c = ChairList[g][1];
            a = Math.floor(Math.random() * 10);
            if (c >= a) {
                f = ChairList[g][0];
                b = ChairList[g][2];
                h = 3;
                k = im.gainGachaponItem(f, b, "皇家礼品袋", h);
                if (k != -1) {
                    j += "#b#t" + k + "##k " + b + "个!\r\n"
                }
            }
            var g = new java.util.Random().nextInt(EquipList.length);
            c = EquipList[g][1];
            a = Math.floor(Math.random() * 10);
            if (c >= a) {
                f = EquipList[g][0];
                b = EquipList[g][2];
                h = 3;
                k = im.gainGachaponItem(f, b, "皇家礼品袋", h);
                if (k != -1) {
                    j += "#b#t" + k + "##k " + b + "个!\r\n"
                }
            }
            if (j == "打开了皇家礼品袋，一共获得了：\r\n") {
                im.sendOk(im.getSpace(1) + "运气真差。。。一个东西都没有得到！！" + c)
            } else {
                im.sendOk(j)
            }
            im.gainItem(im.getItemId(), -1);
            im.dispose()
        }
    }
}
var status = -1;